package net.dgg.zz.production.junctions.service;

import net.dgg.tmd.foundation.platform.datapermission.entity.DataAuthDTO;
import net.dgg.tmd.foundation.platform.datapermission.service.DataPermissionAssocService;
import net.dgg.zz.common.base.service.BaseService;
import net.dgg.zz.production.chargeback.dao.ZzProductOrderDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author 孙上峰
 * @ClassName <ZzJunctionsOrderService>
 * @despriction
 * @create 2018/08/24 10:40
 **/
@Service
public class ZzJunctionsOrderService extends BaseService {

    @Autowired
    private ZzProductOrderDao zzProductOrderDao;
    @Autowired
    private DataPermissionAssocService dataPermissionAssocService;

    /**
     * 查询分页列表
     *
     * @param map {codeName:模块名称}
     * @return List<ScProductOrder>
     */
    @Transactional(readOnly = true)
    public List<Map> queryJunctionsList(Map map) {
        DataAuthDTO dataAuthDTO = dataPermissionAssocService.selectAuthToConfigureRturnOrgIds("zzsc_sc_junctions");
        map.put("dataAuthDTO", dataAuthDTO);
        map.put("userAlias", "t");
        map.put("userColumn", "flow_user_id");
        map.put("deptAlias", "t");
        map.put("deptColumn", "flow_user_org_id");
        Integer count = this.zzProductOrderDao.count(map);
        map.put("count", count);
        if (count <= 0) {
            return new ArrayList<Map>(0);
        }
        List<Map> listPage = zzProductOrderDao.queryMap(map);
        map.put("count", count);
        return listPage;
    }

}
